(async function(){        
    //获取得到奖励的一览表
    setLoading(1);
    var salary = await getMySalary();
    setLoading(0);
    var list = getNode("history");
    var line = list.children[0];
    if(salary.length>0){
        clearAll(list);
        for(var i=salary.length-1;i>=0;i--){
            var si = salary[i];
            if(si.active){
                var f=false;
                var newLine = line.cloneNode(true);
                var reason = getSubNode(newLine,"reason");
                var date = getSubNode(newLine,"time");
                var amount = getSubNode(newLine,"amount");
                reason.innerText = salary[i].reason;
                if (si.period.toNumber()==ONCE){
                    amount.innerText = format(si.amount);
                    date.innerText = dateFormat(si.start);
                    f=true;
                }else if (si.period.toNumber()==DAY){
                    var day;
                    if (si.end.toNumber()==0 || si.end.toNumber() > time()) day = (time() - si.lastPay.toNumber())/DAY;
                    else day = (si.end.toNumber() - si.lastPay.toNumber())/DAY;
                    day = Math.floor(day);
                    if (day>0){
                        //超过1天没领取
                        amount.innerText = parseFloat(format(si.amount))*day;
                        date.innerText = dateFormat(si.lastPay) + " 后共"+day+"天";
                        f=true;
                    }
                }else if (si.period.toNumber()==MONTH){
                    var month;
                    if (si.end.toNumber()==0 || si.end.toNumber() > time()) month = (time() - si.lastPay.toNumber())/MONTH;
                    else month = (si.end.toNumber() - si.lastPay.toNumber())/MONTH;
                    month = Math.floor(month);
                    if (month>0){
                        //超过1个月没领取
                        amount.innerText = parseFloat(format(si.amount))*month;
                        date.innerText = dateFormat(si.lastPay) + " 后共"+month+"月";
                        f=true;
                    }
                }else if (si.period.toNumber()==YEAR){
                    var year;
                    if (si.end.toNumber()==0 || si.end.toNumber() > time()) year = (time() - si.lastPay.toNumber())/YEAR;
                    else year = (si.end.toNumber() - si.lastPay.toNumber())/YEAR;
                    year = Math.floor(year);
                    if (year>0){
                        //超过1年没领取
                        amount.innerText = parseFloat(format(si.amount))*year;
                        date.innerText = dateFormat(si.lastPay) + " 后共"+year+"年";
                        f=true;
                    }
                }
                if (f) list.appendChild(newLine);
            }
        }
    }
})();